package com.example.consumer.config;

import com.example.consumer.bean.City;
import com.example.consumer.service.CityService;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class CityServiceFallbackFactory implements FallbackFactory {
    @Override
    public Object create(Throwable throwable) {
        return new CityService(){
            @Override
            public List<City> findAll() {
                return new ArrayList<City>();
            }

            @Override
            public List<City> findByName(String name) {
                List<City> list = new ArrayList<>();
                City city = new City();
                city.setName("Not Found!");
                list.add(city);
                return list;
            }
        };
    }
}
